<?php

ini_set('display_errors', 1);
require_once '/data/wwwroot/g_vendor/autoload.php';

$min_id = $argv[1] ?? 0;
$max_id = $argv[2] ?? 0;
if ($min_id) {
    if ($max_id == 0) $max_id = \Biz\model\brand\Content::get("id", ['id[>=]' => $min_id,'ORDER' => ['id' => 'DESC'], 'LIMIT' => 1]);
    for ($i = $min_id; $i <= $max_id; $i++) {
        try {
            \Doraemon\model\Elasticsearch\brandContent\BrandContentEs::saveToEsById($i);
        } catch (\Exception $e) {
            echo "id:$i error:" . $e->getMessage(), PHP_EOL;
        }
    }
}
